Skip to content

fix(test): reject empty code get --out and strip code-file BOM#34

Open
SahilRakhaiya05 wants to merge 2 commits into
TestSprite:mainfrom
SahilRakhaiya05:fix/code-get-empty-out-and-code-file-bom
Open

fix(test): reject empty code get --out and strip code-file BOM#34
SahilRakhaiya05 wants to merge 2 commits into
TestSprite:mainfrom
SahilRakhaiya05:fix/code-get-empty-out-and-code-file-bom

Conversation

@SahilRakhaiya05

@SahilRakhaiya05 SahilRakhaiya05 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Two silent-failure fixes in the test command surface:

1. test code get --out with empty inline code

When the API returns an empty/null code body in text mode, the CLI printed a stderr hint and exited 0 - but if --out was set, closeOutputFile() still ran and left a zero-byte file. Agents and scripts checking file existence/size treated that as a successful download.

Fix: abort the file sink, unlink any artifact, and throw VALIDATION_ERROR (exit 5). Stderr-only text mode (no --out) behavior is unchanged.

2. UTF-8 BOM on --code-file

Plan/steps JSON reads already strip a leading BOM from PowerShell 5.1 Set-Content -Encoding utf8 files. readCodeFile() did not - the invisible U+FEFF prefix was uploaded as part of the test source via test code put / test create --code-file.

Fix: apply existing stripBom() in readCodeFile().

Tests

  • runCodeGet: empty inline code + --out ? exit 5, no file left behind; stderr hint preserved without --out
  • runCodePut: BOM-prefixed code file uploads body without BOM

When test code get --out receives an empty inline body, closeOutputFile left a zero-byte file with exit 0 — scripts and agents treated that as a successful download. Abort the sink, unlink any artifact, and surface VALIDATION_ERROR instead.

Plan/steps JSON already strip a leading UTF-8 BOM from PowerShell 5.1 files; apply the same strip to --code-file reads so uploaded test source is not corrupted by an invisible U+FEFF prefix.
Resolve conflicts in test.ts / test.test.ts by combining upstream's
atomic temp-file --out writes with this branch's empty-code rejection
(VALIDATION_ERROR exit 5) and BOM stripping. Update the pre-existing-file
empty-code regression to expect exit 5 while still asserting the file
is untouched.
@zeshi-du

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@zeshi-du, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 67082200-485a-4bf5-aafa-01734f203f7c

📥 Commits

Reviewing files that changed from the base of the PR and between 15e95de and c108903.

📒 Files selected for processing (2)
  • src/commands/test.test.ts
  • src/commands/test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants